package com.wxgo.utils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class OuttypeKit {

	private Map<String, Integer> map = null;

	public OuttypeKit() {
		init();
	}

	private void init() {
		System.out.println("开始初始化数据......");
		List<Record> list = Db.find("select id,type from outtype");
		map = new HashMap<String, Integer>(list.size());
		for (Record record : list) {
			map.put(record.getStr("type"), record.getInt("id"));
		}
		System.out.println("初始化数据结束......");
	}

	public Integer getId(String typeName) {
		if (map == null) {
			init();
		}
		return map.get(typeName);
	}

}
